package com.htudata.hieyes.alarm.controller;


import com.htudata.common.enums.RequestSeqEnum;
import com.htudata.common.enums.RequestStatusEnum;
import com.htudata.convention.domain.ResponseResult;
import com.htudata.core.util.ResultGenerator;
import com.htudata.hieyes.alarm.service.AlarmStatisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class AlarmStatisController {

  @Autowired
  private AlarmStatisService alarmStatisService;
  
  @RequestMapping(value = {"/v1/statis/alarms"}, method = {RequestMethod.GET})
  @ResponseBody
  public ResponseResult getAlarmStatisData(@RequestParam(required = true) String alarmType, @RequestParam(required = true) String a2) {
    try {
      return ResultGenerator.genResult(RequestSeqEnum.SEQ_001.getCode(), this.alarmStatisService
          .getAlarmStatisData(alarmType));
    } catch (Exception e) {
      log.error("getAlarmStatisData",e);
      return ResultGenerator.genErrorResult(RequestSeqEnum.SEQ_001.getCode(), RequestStatusEnum.STATUS_503
          .getCode(), "暂无数据");
    } 
  }
  
  @RequestMapping(value = {"/v1/statis/collects"}, method = {RequestMethod.GET})
  @ResponseBody
  public ResponseResult getDataCollectAlarm(@RequestParam(required = true) String a2) {
    try {
      return ResultGenerator.genResult(RequestSeqEnum.SEQ_010.getCode(), this.alarmStatisService
          .getDataCollectAlarm());
    } catch (Exception e) {
      log.error("getDataCollectAlarm",e);
      return ResultGenerator.genErrorResult(RequestSeqEnum.SEQ_010.getCode(), RequestStatusEnum.STATUS_503
          .getCode(), "暂无数据");
    } 
  }
  
  @RequestMapping(value = {"/v2/statis/collects"}, method = {RequestMethod.GET})
  @ResponseBody
  public ResponseResult getDataCollectAlarm2(@RequestParam(required = true) String a2) {
    try {
      return ResultGenerator.genResult(RequestSeqEnum.SEQ_010.getCode(), this.alarmStatisService
          .getDataCollectAlarm2());
    } catch (Exception e) {
      log.error("getDataCollectAlarm2",e);
      return ResultGenerator.genErrorResult(RequestSeqEnum.SEQ_010.getCode(), RequestStatusEnum.STATUS_503
          .getCode(), "暂无数据");
    } 
  }
  
  @RequestMapping(value = {"/v3/statis/collects"}, method = {RequestMethod.GET})
  @ResponseBody
  public ResponseResult getDataCollectAlarm3(@RequestParam(required = true) String a2) {
    try {
      return ResultGenerator.genResult(RequestSeqEnum.SEQ_010.getCode(), this.alarmStatisService
          .getDataCollectAlarm3());
    } catch (Exception e) {
      log.error("getDataCollectAlarm3",e);
      return ResultGenerator.genErrorResult(RequestSeqEnum.SEQ_010.getCode(), RequestStatusEnum.STATUS_503
          .getCode(), "暂无数据");
    } 
  }
}
